'''
	This file is part of pyNN.
 
 	Copyright 2009 Michael Morckos <mikey.morckos@gmail.com>
 
 	pyNN is free software: you can redistribute it and/or modify
 	it under the terms of the GNU General Public License as published by
 	the Free Software Foundation, either version 3 of the License, or
 	(at your option) any later version.
 
 	pyNN is distributed in the hope that it will be useful,
 	but WITHOUT ANY WARRANTY; without even the implied warranty of
 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 	GNU General Public License for more details.
 
 	You should have received a copy of the GNU General Public License
 	along with pyNN.  If not, see <http://www.gnu.org/licenses/>.
'''

import synapse
import math
import data

class Neuron:
		def __init__(self, bias = False) :
        		self.in_synapses = []
       		 	self.output_signal = 0.0
       		 	self.bias = bias
        	
		def sum_func(self, flag = True) :
				self.output_signal = 0.0
				for i in self.in_synapses :
						self.output_signal += i.src_neuron.get_output_signal() * i.weight	
				if flag :
						self.output_signal = self.sigmoid_func(self.output_signal)
						
		def sigmoid_func(self, value) :
				return 1.0 / (1.0 + (math.e ** (-data.sig_coef * value)))				
				
		def get_output_signal(self) :
			     if self.bias :
			     	   return int(self.bias)
			     return self.output_signal
			    	
